From: Florian Müllner Date: Sat, 19 Jul 2025 12:12:46 +0000 (+0200) Subject: screenshot: Fix taking interactive screenshots via D-Bus X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~116^2^2~48 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4272916830120c0ff858e9b9de5d242a04932632;p=gnome-shell.git screenshot: Fix taking interactive screenshots via D-Bus The D-Bus method relies on the `screenshot-taken` and `closed` signals to differentiate successful operations from canceled/failed ones. However as the `screenshot-taken` signal is emitted asynchronously, it may end up being emitted after the `closed` signal even in case of success. Await the result to ensure correct ordering. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8499 Part-of: --- diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index a6f5e8b37..d96d62b3e 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -1350,7 +1350,7 @@ export const ScreenshotUI = GObject.registerClass({ visible: false, })); this._captureButton.connect('clicked', - this._onCaptureButtonClicked.bind(this)); + () => this._onCaptureButtonClicked().catch(logError)); this._bottomRowContainer.add_child(this._captureButton); this._showPointerButtonContainer = new St.BoxLayout({ @@ -1872,9 +1872,13 @@ export const ScreenshotUI = GObject.registerClass({ return [x, y, w, h]; } - _onCaptureButtonClicked() { + async _onCaptureButtonClicked() { if (this._shotButton.checked) { - this._saveScreenshot().catch(logError); + try { + await this._saveScreenshot(); + } catch (e) { + logError(e); + } this.close(); } else { // Screencast closes the UI on its own. @@ -2142,7 +2146,7 @@ export const ScreenshotUI = GObject.registerClass({ symbol === Clutter.KEY_KP_Enter || symbol === Clutter.KEY_ISO_Enter || ((event.get_state() & Clutter.ModifierType.CONTROL_MASK) && (symbol === Clutter.KEY_c || symbol === Clutter.KEY_C))) { - this._onCaptureButtonClicked(); + this._onCaptureButtonClicked().catch(logError); return Clutter.EVENT_STOP; }